#!/bin/sh

. /opt/truecl/etc/clenv.sh

user=${1:-root}
h=`hostname`

r=`clreq do_ping_connections verbose 1 2>&1 | 
	sed "s/^$h://"  | 
	awk 'NR==1 && $1 != "OK" {print "General do_ping_connections failure!";exit(0);}
		NR>1 && $NF != "OK" {print "Failed to ping " $1};'`


if [ -n "$r" ]
then
	if [ -x "/usr/bin/mailx" ]
	then
		echo "$r" | /usr/bin/mailx -s "Cluster known_net_connections problem" $user
		exit 0
	fi
	if [ -x "/usr/bin/mail" ]
	then
		echo "Subject: Cluster known_net_connections problem\n$r" | 
			/usr/bin/mail $user
	fi
fi

exit 0
